home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
UTILITIES
/
BOGOMIPS.SPK
/
!Desk_Bogo
/
c
/
main
< prev
Wrap
Text File
|
1996-04-28
|
3KB
|
122 lines
/****************************************************************************/
/* !Desk_Bogo - the desktop version */
/* Author - Julyan Bristow */
/* Date - April 1996 */
/* Version - 1.00 */
/****************************************************************************/
#include "main.h"
#include "bogomips.h"
/******************************** GLOBAL DATA *******************************/
char *Author = "Julyan Bristow";
char *Version = "1.00 - April 1996";
static dbox dmain;
unsigned long whole, fraction;
/**************************** GENERAL FUNCTIONS *****************************/
void result_to_string(char *format, ...)
{
char result[32];
va_list va;
va_start(va, format);
vsprintf(result, format, va);
va_end(va);
dbox_setfield(dmain, output_icon, result);
}
static void info(void)
{
dbox d_info;
if (d_info = dbox_new("ProgInfo"), d_info != NULL)
{
dbox_setfield(d_info, Info_version, Version);
dbox_setfield(d_info, Author_field, Author);
dbox_show(d_info); dbox_fillin(d_info); dbox_dispose(&d_info);
}
}
/****************************** EVENT HANDLERS ******************************/
static BOOL dmain_ehandler(dbox box, void *ev, void *handle)
{
wimp_eventstr *e=(wimp_eventstr*) ev;
handle = handle;
switch (e->e) {
case wimp_EOPEN:
wimp_open_wind(&e->data.o);
break;
case wimp_ECLOSE:
exit(0); /* just quit */
break;
case wimp_EBUT:
switch (e->data.but.m.i) {
case start_icon:
dbox_setfield(dmain, output_icon, msgs_lookup("mess3"));
if (!bogo_mips_main(&whole, &fraction))
{ werr(0,msgs_lookup("mess3")); exit(0);
break;
}
result_to_string("%s%u.%u",msgs_lookup("mess2"), whole, fraction);
break;
case cancel_icon:
exit(0); /* just quit */
break;
case info_icon:
info();
break;
default:
break;
}
default:
break;
}
return TRUE;
}
/****************************** INITIALISATION ******************************/
static BOOL bogo_mips_initialise(void)
{
auto wimp_wstate boxstatus;
wimpt_init("desk_bogo");
res_init("desk_bogo");
template_init();
dbox_init();
msgs_init();
/* create the main dialogue box */
if (dmain = dbox_new("Main"),dmain == 0) { werr(0, msgs_lookup("err1")); return (FALSE); }
dbox_raw_eventhandler(dmain, dmain_ehandler, 0);
wimp_get_wind_state(dbox_syshandle(dmain), &boxstatus);
position_box(&boxstatus.o, MIDDLE_CENTRE); /* get info to open error box in centre of screen */
wimp_open_wind(&boxstatus.o); /* then open the window in that position */
dbox_setfield(dmain, output_icon, msgs_lookup("mess1"));
win_activeinc();
return TRUE;
}
/******************************* MAIN PROGRAM ********************************/
/*--- Main entry point. ---*/
int main()
{
if (bogo_mips_initialise())
{
event_setmask(wimp_EMPTRENTER|wimp_EMPTRLEAVE);
while (TRUE)
event_process();
}
return FALSE;
}